https://gallery.technet.microsoft.com/scriptcenter/Powershell-script-to-5edcdaea<\/a><\/p>","upvoteCount":0,"datePublished":"2016-12-13T16:56:56.000Z","url":"https://community.spiceworks.com/t/getaduser-error-in-powershell-script/546721/4","author":{"@type":"Person","name":"ramiromaldonado3","url":"https://community.spiceworks.com/u/ramiromaldonado3"}},{"@type":"Answer","text":"Does the server you are running this on have the Active Directory role installed on it? I know to have the get-aduser command available on desktops RSAT needs to be installed. So, it is possible that the Powershell commands only become available if the module is installed when the role is configured.<\/p>","upvoteCount":1,"datePublished":"2016-12-13T17:01:41.000Z","url":"https://community.spiceworks.com/t/getaduser-error-in-powershell-script/546721/5","author":{"@type":"Person","name":"jjoyner1985","url":"https://community.spiceworks.com/u/jjoyner1985"}},{"@type":"Answer","text":"
Yes sir Active Directory role is installed.<\/p>","upvoteCount":0,"datePublished":"2016-12-13T17:04:03.000Z","url":"https://community.spiceworks.com/t/getaduser-error-in-powershell-script/546721/6","author":{"@type":"Person","name":"ramiromaldonado3","url":"https://community.spiceworks.com/u/ramiromaldonado3"}},{"@type":"Answer","text":"
I am even running this directly off of my AD server. This seems really odd to me.<\/p>","upvoteCount":0,"datePublished":"2016-12-13T17:06:22.000Z","url":"https://community.spiceworks.com/t/getaduser-error-in-powershell-script/546721/7","author":{"@type":"Person","name":"ramiromaldonado3","url":"https://community.spiceworks.com/u/ramiromaldonado3"}},{"@type":"Answer","text":"
Try { \n Get-ADUser -server \"dc.contoso.com\" -Filter {enabled -eq $true} -ErrorAction Stop\n} Catch [ADIdentityNotFoundException] {\n $_\n}\n\n<\/code><\/pre>\nsee what error comes up.<\/p>\n
may be remote server do not have ad web services installed<\/p>","upvoteCount":0,"datePublished":"2016-12-13T17:09:56.000Z","url":"https://community.spiceworks.com/t/getaduser-error-in-powershell-script/546721/8","author":{"@type":"Person","name":"jitensh","url":"https://community.spiceworks.com/u/jitensh"}},{"@type":"Answer","text":"
At line:3 char:3\n+ } Catch [ADIdentityNotFoundException] {\n+ ~~~~~\nUnexpected token 'Catch' in expression or statement.\n + CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException\n + FullyQualifiedErrorId : UnexpectedToken\n<\/code><\/pre>","upvoteCount":0,"datePublished":"2016-12-13T17:13:39.000Z","url":"https://community.spiceworks.com/t/getaduser-error-in-powershell-script/546721/9","author":{"@type":"Person","name":"ramiromaldonado3","url":"https://community.spiceworks.com/u/ramiromaldonado3"}},{"@type":"Answer","text":"How about something easy?<\/p>\n
Get-ADUser -filter *\n<\/code><\/pre>\nRun from the DC logged into a domain admin account through an administrative Powershell window.<\/p>","upvoteCount":0,"datePublished":"2016-12-13T17:25:36.000Z","url":"https://community.spiceworks.com/t/getaduser-error-in-powershell-script/546721/10","author":{"@type":"Person","name":"jjoyner1985","url":"https://community.spiceworks.com/u/jjoyner1985"}},{"@type":"Answer","text":"
lets simply catch the warning<\/p>\n
try {\nGet-ADUser -server \"dc.contoso.com\" -Filter {enabled -eq $true} -ErrorAction Stop\n}\ncatch \n{\nWrite-Warning “$_”\n}\n<\/code><\/pre>","upvoteCount":1,"datePublished":"2016-12-13T17:25:45.000Z","url":"https://community.spiceworks.com/t/getaduser-error-in-powershell-script/546721/11","author":{"@type":"Person","name":"jitensh","url":"https://community.spiceworks.com/u/jitensh"}},{"@type":"Answer","text":"WARNING: Unable to contact the server. This may be because this server does not exist, it is currently down, or it does not have the Active Directory Web Services running.\n<\/code><\/pre>\nAhhhhh<\/p>","upvoteCount":0,"datePublished":"2016-12-13T17:28:52.000Z","url":"https://community.spiceworks.com/t/getaduser-error-in-powershell-script/546721/12","author":{"@type":"Person","name":"ramiromaldonado3","url":"https://community.spiceworks.com/u/ramiromaldonado3"}},{"@type":"Answer","text":"
I think I’ve found something. Does your search base include “OU=Users” (referencing the built-in Users OU of AD)? If so, change that to “CN=Users” as the built-in Users is a container, not an organizational unit.<\/p>","upvoteCount":1,"datePublished":"2016-12-13T17:29:40.000Z","url":"https://community.spiceworks.com/t/getaduser-error-in-powershell-script/546721/13","author":{"@type":"Person","name":"jjoyner1985","url":"https://community.spiceworks.com/u/jjoyner1985"}},{"@type":"Answer","text":"
Changed to CN and still same thing.<\/p>","upvoteCount":0,"datePublished":"2016-12-13T17:32:17.000Z","url":"https://community.spiceworks.com/t/getaduser-error-in-powershell-script/546721/14","author":{"@type":"Person","name":"ramiromaldonado3","url":"https://community.spiceworks.com/u/ramiromaldonado3"}},{"@type":"Answer","text":"
try this way?<\/p>\n
$credential = Get-Credential -Credential domain\\administrator\n\n$session = New-PSSession -cn dc.contoso.com -Credential $credential -Authentication Credssp\n\nInvoke-Command -Session $session -ScriptBlock { Import-Module ActiveDirectory; Get-ADUser -Filter {enabled -eq $true} }\n<\/code><\/pre>\nBut are you sure AD and ps module is installed on remote server?<\/p>","upvoteCount":0,"datePublished":"2016-12-13T17:33:28.000Z","url":"https://community.spiceworks.com/t/getaduser-error-in-powershell-script/546721/15","author":{"@type":"Person","name":"jitensh","url":"https://community.spiceworks.com/u/jitensh"}},{"@type":"Answer","text":"
Get-ADUser : Directory object not found\nAt C:\\Users\\****\\Desktop\\PS\\RMADGRAB.ps1:17 char:15\n+ $AllADUsers = Get-ADUser -server $ADServer `\n+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n + CategoryInfo : ObjectNotFound: (:) [Get-ADUser], ADIdentityNotFoundException\n + FullyQualifiedErrorId : ActiveDirectoryCmdlet:Microsoft.ActiveDirectory.Management.ADIdentityNotFoundException,Microsoft.ActiveDirectory.Management.Commands.GetADUser\n<\/code><\/pre>\nI keep getting this<\/p>","upvoteCount":0,"datePublished":"2016-12-13T17:33:48.000Z","url":"https://community.spiceworks.com/t/getaduser-error-in-powershell-script/546721/16","author":{"@type":"Person","name":"ramiromaldonado3","url":"https://community.spiceworks.com/u/ramiromaldonado3"}},{"@type":"Answer","text":"